<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function MaxGongYue(m, n) {
            // 方法一
            // var min = m < n ? m : n;
            // for (var i = min; i >= 1; i--) {
            //     if (m % i == 0 && n % i == 0) {
            //         return i
            //     }

            // }
        while(n>0){
            var yu= m%n;
          m=n;
          n=yu;
            
        }return m;
        }
        var max = MaxGongYue(2, 9)
        document.write(max)
    </script>
</body>

</html>